package com.sky.lightleafpicturepavilionserver.config;

import com.sky.lightleafpicturepavilionserver.service.SystemConfigService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 系统配置初始化器
 * 在应用启动时自动初始化默认配置
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class SystemConfigInitializer implements ApplicationRunner {

    private final SystemConfigService systemConfigService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("开始初始化系统配置...");
        
        try {
            systemConfigService.initDefaultConfigs();
            log.info("系统配置初始化完成");
        } catch (Exception e) {
            log.error("系统配置初始化失败", e);
        }
    }
}